//
//  WBStatusForwardCell.swift
//  微博
//
//  Created by lipengfei on 15/9/10.
//  Copyright © 2015年 lipengfei. All rights reserved.
//

import UIKit

class WBStatusForwardCell: WBStatusCell {

    
    ///重写父类的 微博数据视图模型
    override var statusViewModel:WBStatusViewModel?{
        didSet{
            forwardLabel.text = statusViewModel?.forwardText
        }
        
    }
    
    override func setupUI() {
        //转发微博中，依然显示父类中的信息，所以需要重写父类的setupUI（）
        super.setupUI()
        // 添加控件
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: pictureView)
        
        //设置布局
        // 1.背景按钮 ：上面是内容视图 下面 是底部视图
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -WBStatusCellMargin, y: WBStatusCellMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: WBStatusCellMargin, y: WBStatusCellMargin))
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: WBStatusPictureMaxWidth, height: WBStatusPictureMaxWidth), offset: CGPoint(x: 0, y: WBStatusCellMargin))
        pictureViewWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureViewTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    
    
    
    
    
    ///懒加载
    ///背景按钮，转发的微博可以被点击
    private lazy var backButton:UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return button
    }()
    //转发微博的文字
    private lazy var forwardLabel:UILabel = UILabel(title: "转发微博转发微博转发微博转发微博转发微博转发微博", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth:UIScreen.mainScreen().bounds.width - 2 * WBStatusCellMargin)
    
  }
